package com.xmhmyh.generalframework.project.sys.controller;

import com.xmhmyh.generalframework.framework.webSocket.WebSocketMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 于丁
 * @DateTime: 2021/6/29 2:09 下午
 */
@RestController
@RequestMapping("ws")
public class WebSocketController {

    @Autowired
    private WebSocketMessage webSocketMessage;

    @GetMapping("sendAllMessage/{message}")
    public void sendAllMessageHandler(@PathVariable("message") String message) {
        webSocketMessage.sendAllMessage(message);
        System.out.println(message);
    }

    @GetMapping("sendMessage/{userId}/{message}")
    public void sendMessageHandler(@PathVariable("message") String message, @PathVariable("userId") String userId) {
        webSocketMessage.sendOneMessage(userId,message);
        System.out.println(message);
    }
}
